<?php
if (!defined('URL')) include('../includes/definer.php');
if (!defined('BOOTSTRAP')) include(INC.'admin/php/bootstrap.php');
$q = Doctrine_Query::create()
        ->select('p.id, p.slug as slug, p.titulo as titulo, i.src as portada')
        ->from('Publicacion p')
        ->innerJoin('p.imagenes i')
        ->innerJoin('p.categoria c')
        ->where('p.id_estado = ?', Estado::VISIBLE)
        ->whereNotIn('c.slug', array('prensa', 'about-me', 'home'))
        ->limit(6)
        ->offset(1)
        ->orderBy('p.created_at desc, i.orden')
        ->groupBy('p.id')
;
if (isset($POST)) $q->andWhere('p.id <> ?', $POST->id);
$posts = $q->execute(array(), Doctrine::HYDRATE_ARRAY);
$html = '';
foreach ($posts as $post) {
    $html .= '<a href="post/'.$post['slug'].'" style="background-image: url(\'content/images/thumb/'.$post['portada'].'\')"><span class="tooltip">'.$post['titulo'].'</span></a>';
}
echo($html);
?>